Add error codes duplicates check#68639
Add error codes duplicates check#68639GuillaumeGomez wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
e266deb to
ddc5b9e
Compare
|
Fixed formatting issue. |
|
I don't have much time to do review here, so would appreciate a more elaborate PR description that tells me:
|
|
It counts the occurences of all error code, and detects the duplicates: you're not supposed to be able to use a same error code in two different places (otherwise, we might use one error code for two different errors). So the check is pretty simple in itself: we read files, count the occurrences and check the numbers. Before that, it was done through a macro which has been removed since then. |
Mark-Simulacrum
left a comment
There was a problem hiding this comment.
Looks like this currently depends on the other PR, too, as we currently have non-stringy error codes.
| } | ||
| println!("Found {} error codes with no tests", errors.len()); | ||
| if !errors.is_empty() { | ||
| if !errors.is_empty() || errors_count != 0 { |
There was a problem hiding this comment.
Can we instead push into the errors vec instead of having two separate modes?
|
Do we have consensus as to not having duplicate error code usage? I personally feel like that's a pretty odd policy to have, but if @estebank and @rust-lang/wg-diagnostics feel that we should enforce this then I'm not opposed. |
|
The policy existed for error codes because it was easy to mix up numbers. If we move to stringy error codes, all we need is a check that each has a test emitting it. |
|
@oli-obk That's only true if we truly stringify error codes (e.g. But if mixing up number is the concern, then I guess we can do this. I still feel like that's something that can be fixed whenever it comes up and this doesn't in practice help much, but I also don't usually write errors or diagnostics in general :) |
We've never had problems with this because we've had this check. I have no idea if it would be a problem in practice ;) |
|
We've not had this check for... some time now, right? In any case, I guess it doesn't matter. I'm fine with landing this (once my comments are resolved), and I probably also need to do another review pass after that to make sure the implementation is doing what it says it is. |
|
I think there was some discussion in Zulip as well, but I don't have time to track that down anyway. The code here is (loosely) waiting on the diagnostics WG anyway probably or blocked on the other PR. Moving to waiting-on-team. |
|
@rustbot modify labels to +T-compiler |
|
Discussed in T-compiler meeting. reassigning to @oli-obk as member of WG-diagnostics to decide whether to close as unnecessary, or to land. |
|
Closing as we haven't had this check for quite a while and don't seem to have problems without it. |
|
I strongly disagree on this opinion: before I migrated to the |
I am confused by this -- I thought this lint was for accidentally reusing the same error code (accidentally), not about not having an error code? I've just re-read your comment #68639 (comment) and I feel like it matches my understanding, so it may be helpful to open a new issue or PR instead? Or maybe I'm just misunderstanding... |
|
The other lint checks if all error codes have an explanation. This lint checks that each error code is only used once. |
|
I am in agreement with @oli-obk and @Mark-Simulacrum. One thing I noted at the meeting is that disallowing reusing an error code can have ungreat architectural implications force you have to have |
|
At this point, I just wonder why I try to maintain/clean up this whole error system. No one wants it and no one wants to make another. That's one problem less off my shoulders. Good luck! |
As asked in #67086.
r? @Mark-Simulacrum